package cn.webdai.rabbitmq.example_01;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 消息的发送者(直接模式)
 * @author 戴金华
 * @date 2019-12-04 15:22
 */
@Component
public class MessageSender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(){
        String message = "hello"+new Date();
        System.out.println("发送者发送的消息:"+message);
        this.amqpTemplate.convertAndSend("hello",message);
    }
}
